home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / forms / datawiz / dfd.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-12  |  45.4 KB  |  1,353 lines

  1. VERSION 4.00
  2. Begin VB.Form frmDFD 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Data Form Wizard"
  5.    ClientHeight    =   6480
  6.    ClientLeft      =   885
  7.    ClientTop       =   630
  8.    ClientWidth     =   8205
  9.    Height          =   6885
  10.    Icon            =   "DFD.frx":0000
  11.    Left            =   825
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   6480
  16.    ScaleWidth      =   8205
  17.    Top             =   285
  18.    Width           =   8325
  19.    Begin VB.Frame fraStep 
  20.       Caption         =   " Recordsource "
  21.       Height          =   3750
  22.       Index           =   2
  23.       Left            =   1080
  24.       TabIndex        =   6
  25.       Top             =   1200
  26.       Width           =   6750
  27.       Begin VB.ListBox lstSQL 
  28.          Height          =   1620
  29.          Left            =   2040
  30.          TabIndex        =   45
  31.          TabStop         =   0   'False
  32.          Top             =   1920
  33.          Width           =   4335
  34.       End
  35.       Begin VB.ComboBox cboRecordSource 
  36.          Height          =   315
  37.          Left            =   2040
  38.          TabIndex        =   7
  39.          Top             =   1320
  40.          Width           =   4335
  41.       End
  42.       Begin VB.Label lblSQL 
  43.          Caption         =   "Field list reference for Select statement"
  44.          Height          =   975
  45.          Left            =   840
  46.          TabIndex        =   46
  47.          Top             =   1920
  48.          Width           =   1095
  49.          WordWrap        =   -1  'True
  50.       End
  51.       Begin VB.Label Label4 
  52.          Caption         =   "2"
  53.          BeginProperty Font 
  54.             name            =   "MS Sans Serif"
  55.             charset         =   0
  56.             weight          =   400
  57.             size            =   24
  58.             underline       =   0   'False
  59.             italic          =   0   'False
  60.             strikethrough   =   0   'False
  61.          EndProperty
  62.          ForeColor       =   &H000000FF&
  63.          Height          =   495
  64.          Left            =   600
  65.          TabIndex        =   29
  66.          Top             =   360
  67.          Width           =   375
  68.       End
  69.       Begin VB.Line Line1 
  70.          BorderWidth     =   3
  71.          X1              =   360
  72.          X2              =   6360
  73.          Y1              =   1080
  74.          Y2              =   1080
  75.       End
  76.       Begin VB.Label lblLabels 
  77.          AutoSize        =   -1  'True
  78.          Caption         =   "RecordSource: "
  79.          Height          =   195
  80.          Index           =   6
  81.          Left            =   840
  82.          TabIndex        =   9
  83.          Top             =   1440
  84.          Width           =   1125
  85.       End
  86.       Begin VB.Label lblLabels 
  87.          Alignment       =   2  'Center
  88.          Caption         =   "Select a Table/QueryDef from the list or enter a SQL statement.."
  89.          ForeColor       =   &H00FF0000&
  90.          Height          =   495
  91.          Index           =   4
  92.          Left            =   1320
  93.          TabIndex        =   8
  94.          Top             =   480
  95.          Width           =   2445
  96.       End
  97.    End
  98.    Begin VB.Frame fraStep 
  99.       Caption         =   " Database "
  100.       Height          =   3750
  101.       Index           =   1
  102.       Left            =   720
  103.       TabIndex        =   1
  104.       Top             =   1320
  105.       Width           =   6750
  106.       Begin VB.CommandButton cmdOpenDB 
  107.          Caption         =   "&Open Database..."
  108.          Height          =   375
  109.          Left            =   2040
  110.          TabIndex        =   32
  111.          Top             =   2160
  112.          Width           =   1935
  113.       End
  114.       Begin VB.ComboBox cboConnect 
  115.          Height          =   315
  116.          ItemData        =   "DFD.frx":030A
  117.          Left            =   2040
  118.          List            =   "DFD.frx":032C
  119.          TabIndex        =   2
  120.          Top             =   1440
  121.          Width           =   4335
  122.       End
  123.       Begin VB.Label Label3 
  124.          Caption         =   "1."
  125.          BeginProperty Font 
  126.             name            =   "MS Sans Serif"
  127.             charset         =   0
  128.             weight          =   400
  129.             size            =   24
  130.             underline       =   0   'False
  131.             italic          =   0   'False
  132.             strikethrough   =   0   'False
  133.          EndProperty
  134.          ForeColor       =   &H000000FF&
  135.          Height          =   375
  136.          Left            =   360
  137.          TabIndex        =   34
  138.          Top             =   360
  139.          Width           =   615
  140.       End
  141.       Begin VB.Label Label2 
  142.          Caption         =   "Provide a database name and connect string."
  143.          ForeColor       =   &H00FF0000&
  144.          Height          =   375
  145.          Left            =   960
  146.          TabIndex        =   33
  147.          Top             =   480
  148.          Width           =   1935
  149.       End
  150.       Begin MSComDlg.CommonDialog dlgDBOpen 
  151.          Left            =   6000
  152.          Top             =   2040
  153.          _Version        =   65536
  154.          _ExtentX        =   847
  155.          _ExtentY        =   847
  156.          _StockProps     =   0
  157.       End
  158.       Begin VB.Label lblLabels 
  159.          AutoSize        =   -1  'True
  160.          Caption         =   "Database Name: "
  161.          Height          =   195
  162.          Index           =   1
  163.          Left            =   480
  164.          TabIndex        =   5
  165.          Top             =   2160
  166.          Width           =   1245
  167.       End
  168.       Begin VB.Label lblLabels 
  169.          AutoSize        =   -1  'True
  170.          Caption         =   "Connect String: "
  171.          Height          =   195
  172.          Index           =   2
  173.          Left            =   480
  174.          TabIndex        =   4
  175.          Top             =   1500
  176.          Width           =   1140
  177.       End
  178.       Begin VB.Label lblDatabaseName 
  179.          ForeColor       =   &H00FF0000&
  180.          Height          =   255
  181.          Left            =   1800
  182.          TabIndex        =   3
  183.          Top             =   3015
  184.          Width           =   4470
  185.          WordWrap        =   -1  'True
  186.       End
  187.    End
  188.    Begin VB.CommandButton cmdCancel 
  189.       Caption         =   "&Cancel"
  190.       Height          =   375
  191.       Left            =   5280
  192.       TabIndex        =   43
  193.       Top             =   5520
  194.       Width           =   1455
  195.    End
  196.    Begin VB.CommandButton cmdMove 
  197.       Caption         =   "<< &Previous"
  198.       Height          =   375
  199.       Index           =   1
  200.       Left            =   240
  201.       TabIndex        =   42
  202.       Top             =   5520
  203.       Width           =   1335
  204.    End
  205.    Begin VB.CommandButton cmdMove 
  206.       Caption         =   "&Next >>"
  207.       Height          =   375
  208.       Index           =   0
  209.       Left            =   1680
  210.       TabIndex        =   41
  211.       Top             =   5520
  212.       Width           =   1335
  213.    End
  214.    Begin VB.Frame fraStep 
  215.       Caption         =   "Form info "
  216.       Height          =   3750
  217.       Index           =   5
  218.       Left            =   3360
  219.       TabIndex        =   25
  220.       Top             =   1560
  221.       Width           =   6750
  222.       Begin VB.CheckBox chkOnScreen 
  223.          Caption         =   "On Screen"
  224.          Height          =   210
  225.          Left            =   240
  226.          TabIndex        =   44
  227.          Top             =   3240
  228.          Value           =   1  'Checked
  229.          Width           =   1875
  230.       End
  231.       Begin VB.TextBox txtFormName 
  232.          Height          =   285
  233.          Left            =   3615
  234.          MaxLength       =   8
  235.          TabIndex        =   30
  236.          Top             =   2760
  237.          Width           =   1095
  238.       End
  239.       Begin VB.CheckBox chkLineUnder 
  240.          Caption         =   "Line Under Headline"
  241.          Height          =   255
  242.          Left            =   1080
  243.          TabIndex        =   27
  244.          Top             =   2040
  245.          Width           =   2415
  246.       End
  247.       Begin VB.TextBox txtHeadline 
  248.          Height          =   285
  249.          Left            =   1080
  250.          TabIndex        =   26
  251.          Top             =   1560
  252.          Width           =   2775
  253.       End
  254.       Begin VB.Label Label7 
  255.          Caption         =   "5"
  256.          BeginProperty Font 
  257.             name            =   "MS Sans Serif"
  258.             charset         =   0
  259.             weight          =   400
  260.             size            =   24
  261.             underline       =   0   'False
  262.             italic          =   0   'False
  263.             strikethrough   =   0   'False
  264.          EndProperty
  265.          ForeColor       =   &H000000FF&
  266.          Height          =   495
  267.          Left            =   360
  268.          TabIndex        =   40
  269.          Top             =   240
  270.          Width           =   375
  271.       End
  272.       Begin VB.Label lblLabels 
  273.          Alignment       =   2  'Center
  274.          Caption         =   "Select a caption for the top of form and a formname."
  275.          ForeColor       =   &H00FF0000&
  276.          Height          =   495
  277.          Index           =   9
  278.          Left            =   960
  279.          TabIndex        =   39
  280.          Top             =   480
  281.          Width           =   2445
  282.       End
  283.       Begin VB.Label lblLabels 
  284.          AutoSize        =   -1  'True
  285.          Caption         =   "Base Form Name (w/o Extension): "
  286.          Height          =   195
  287.          Index           =   0
  288.          Left            =   960
  289.          TabIndex        =   31
  290.          Top             =   2760
  291.          Width           =   2460
  292.       End
  293.       Begin VB.Label Label1 
  294.          Caption         =   "Headline"
  295.          Height          =   255
  296.          Left            =   1080
  297.          TabIndex        =   28
  298.          Top             =   1200
  299.          Width           =   1215
  300.       End
  301.    End
  302.    Begin VB.Frame fraStep 
  303.       Caption         =   " Appearance "
  304.       Height          =   3750
  305.       Index           =   4
  306.       Left            =   1560
  307.       TabIndex        =   21
  308.       Top             =   1320
  309.       Width           =   6750
  310.       Begin VB.OptionButton optLook 
  311.          Caption         =   "3D"
  312.          Height          =   255
  313.          Index           =   0
  314.          Left            =   2640
  315.          TabIndex        =   24
  316.          Top             =   1320
  317.          Width           =   855
  318.       End
  319.       Begin VB.OptionButton optLook 
  320.          Caption         =   "2D"
  321.          Height          =   255
  322.          Index           =   1
  323.          Left            =   2640
  324.          TabIndex        =   23
  325.          Top             =   1680
  326.          Width           =   855
  327.       End
  328.       Begin VB.OptionButton optLook 
  329.          Caption         =   "View "
  330.          Height          =   255
  331.          Index           =   2
  332.          Left            =   2640
  333.          TabIndex        =   22
  334.          Top             =   2040
  335.          Width           =   855
  336.       End
  337.       Begin VB.Label Label6 
  338.          Caption         =   "4"
  339.          BeginProperty Font 
  340.             name            =   "MS Sans Serif"
  341.             charset         =   0
  342.             weight          =   400
  343.             size            =   24
  344.             underline       =   0   'False
  345.             italic          =   0   'False
  346.             strikethrough   =   0   'False
  347.          EndProperty
  348.          ForeColor       =   &H000000FF&
  349.          Height          =   495
  350.          Left            =   720
  351.          TabIndex        =   38
  352.          Top             =   240
  353.          Width           =   375
  354.       End
  355.       Begin VB.Label lblLabels 
  356.          Alignment       =   2  'Center
  357.          Caption         =   "Select a look for the controls you create"
  358.          ForeColor       =   &H00FF0000&
  359.          Height          =   495
  360.          Index           =   8
  361.          Left            =   1440
  362.          TabIndex        =   37
  363.          Top             =   360
  364.          Width           =   2445
  365.       End
  366.    End
  367.    Begin VB.Frame fraStep 
  368.       Caption         =   " Fields to include "
  369.       Height          =   3750
  370.       Index           =   3
  371.       Left            =   2400
  372.       TabIndex        =   10
  373.       Top             =   120
  374.       Width           =   6750
  375.       Begin VB.ListBox lstFields 
  376.          DragIcon        =   "DFD.frx":039B
  377.          Height          =   1620
  378.          Left            =   480
  379.          MultiSelect     =   2  'Extended
  380.          TabIndex        =   17
  381.          Top             =   1200
  382.          Width           =   2535
  383.       End
  384.       Begin VB.ListBox lstIncludedFields 
  385.          DragIcon        =   "DFD.frx":06A5
  386.          Height          =   1620
  387.          Left            =   3720
  388.          MultiSelect     =   2  'Extended
  389.          TabIndex        =   16
  390.          Top             =   1200
  391.          Width           =   2655
  392.       End
  393.       Begin VB.CommandButton cmdMoveFields 
  394.          Caption         =   ">>"
  395.          BeginProperty Font 
  396.             name            =   "MS Sans Serif"
  397.             charset         =   0
  398.             weight          =   700
  399.             size            =   8.25
  400.             underline       =   0   'False
  401.             italic          =   0   'False
  402.             strikethrough   =   0   'False
  403.          EndProperty
  404.          Height          =   375
  405.          Index           =   0
  406.          Left            =   3120
  407.          TabIndex        =   15
  408.          Top             =   1200
  409.          Width           =   495
  410.       End
  411.       Begin VB.CommandButton cmdMoveFields 
  412.          Caption         =   ">"
  413.          BeginProperty Font 
  414.             name            =   "MS Sans Serif"
  415.             charset         =   0
  416.             weight          =   700
  417.             size            =   8.25
  418.             underline       =   0   'False
  419.             italic          =   0   'False
  420.             strikethrough   =   0   'False
  421.          EndProperty
  422.          Height          =   375
  423.          Index           =   1
  424.          Left            =   3120
  425.          TabIndex        =   14
  426.          Top             =   1680
  427.          Width           =   495
  428.       End
  429.       Begin VB.CommandButton cmdMoveFields 
  430.          Caption         =   "<"
  431.          BeginProperty Font 
  432.             name            =   "MS Sans Serif"
  433.             charset         =   0
  434.             weight          =   700
  435.             size            =   8.25
  436.             underline       =   0   'False
  437.             italic          =   0   'False
  438.             strikethrough   =   0   'False
  439.          EndProperty
  440.          Height          =   375
  441.          Index           =   2
  442.          Left            =   3120
  443.          TabIndex        =   13
  444.          Top             =   2160
  445.          Width           =   495
  446.       End
  447.       Begin VB.CommandButton cmdMoveFields 
  448.          Caption         =   "<<"
  449.          BeginProperty Font 
  450.             name            =   "MS Sans Serif"
  451.             charset         =   0
  452.             weight          =   700
  453.             size            =   8.25
  454.             underline       =   0   'False
  455.             italic          =   0   'False
  456.             strikethrough   =   0   'False
  457.          EndProperty
  458.          Height          =   375
  459.          Index           =   3
  460.          Left            =   3120
  461.          TabIndex        =   12
  462.          Top             =   2640
  463.          Width           =   495
  464.       End
  465.       Begin VB.ListBox lstOLECtls 
  466.          BeginProperty Font 
  467.             name            =   "MS Sans Serif"
  468.             charset         =   0
  469.             weight          =   700
  470.             size            =   8.25
  471.             underline       =   0   'False
  472.             italic          =   0   'False
  473.             strikethrough   =   0   'False
  474.          EndProperty
  475.          Height          =   450
  476.          Left            =   480
  477.          TabIndex        =   11
  478.          Top             =   2760
  479.          Visible         =   0   'False
  480.          Width           =   615
  481.       End
  482.       Begin VB.Label Label5 
  483.          Caption         =   "3"
  484.          BeginProperty Font 
  485.             name            =   "MS Sans Serif"
  486.             charset         =   0
  487.             weight          =   400
  488.             size            =   24
  489.             underline       =   0   'False
  490.             italic          =   0   'False
  491.             strikethrough   =   0   'False
  492.          EndProperty
  493.          ForeColor       =   &H000000FF&
  494.          Height          =   495
  495.          Left            =   480
  496.          TabIndex        =   36
  497.          Top             =   240
  498.          Width           =   375
  499.       End
  500.       Begin VB.Label lblLabels 
  501.          Alignment       =   2  'Center
  502.          Caption         =   "Select fields and field order."
  503.          ForeColor       =   &H00FF0000&
  504.          Height          =   255
  505.          Index           =   5
  506.          Left            =   1320
  507.          TabIndex        =   35
  508.          Top             =   360
  509.          Width           =   2445
  510.       End
  511.       Begin VB.Label lblLabels 
  512.          AutoSize        =   -1  'True
  513.          Caption         =   " Drag/Drop to Change Order "
  514.          ForeColor       =   &H00FF0000&
  515.          Height          =   195
  516.          Index           =   7
  517.          Left            =   1440
  518.          TabIndex        =   20
  519.          Top             =   600
  520.          Width           =   2070
  521.       End
  522.       Begin VB.Label lblLabels 
  523.          AutoSize        =   -1  'True
  524.          Caption         =   "Available Columns: "
  525.          Height          =   195
  526.          Index           =   3
  527.          Left            =   480
  528.          TabIndex        =   19
  529.          Top             =   960
  530.          Width           =   1380
  531.       End
  532.       Begin VB.Label lblLabels 
  533.          AutoSize        =   -1  'True
  534.          Caption         =   "Included Columns: "
  535.          Height          =   195
  536.          Index           =   10
  537.          Left            =   3720
  538.          TabIndex        =   18
  539.          Top             =   960
  540.          Width           =   1350
  541.       End
  542.    End
  543.    Begin VB.CommandButton cmdFinish 
  544.       Caption         =   "&Build the Form"
  545.       Enabled         =   0   'False
  546.       Height          =   375
  547.       Left            =   3720
  548.       TabIndex        =   0
  549.       Top             =   5520
  550.       Width           =   1455
  551.    End
  552. Attribute VB_Name = "frmDFD"
  553. Attribute VB_Creatable = False
  554. Attribute VB_Exposed = False
  555. Option Explicit
  556. Dim mdbCurrentDB As Database
  557. Dim msDBName As String
  558. Dim mrecRS As Recordset
  559. Dim mnDataType As Integer
  560. 'set in the look panel
  561. Public iScreenStyle As Integer
  562. 'constants used for the data type of the database
  563. Const gnDT_NONE = -1
  564. Const gnDT_ACCESS = 0
  565. Const gnDT_DBASEIV = 1
  566. Const gnDT_DBASEIII = 2
  567. Const gnDT_FOXPRO26 = 3
  568. Const gnDT_FOXPRO25 = 4
  569. Const gnDT_FOXPRO20 = 5
  570. Const gnDT_PARADOX4X = 6
  571. Const gnDT_PARADOX3X = 7
  572. Const gnDT_BTRIEVE = 8
  573. Const gnDT_ODBC = 9
  574. 'dealing with screen types
  575. Const Screen_3d = 0
  576. Const Screen_2d = 1
  577. Const Screen_View = 2
  578. Private Sub cboConnect_Change()
  579.   msDBName = ""
  580.   mnDataType = gnDT_NONE
  581.   lblDatabaseName.Caption = msDBName
  582.   cboRecordSource.Clear
  583.   Set mrecRS = Nothing
  584.   lstFields.Clear
  585.   lstIncludedFields.Clear
  586. End Sub
  587. Private Sub cboConnect_Click()
  588.   Call cboConnect_Change
  589.   mnDataType = cboConnect.ListIndex
  590. End Sub
  591. Private Sub cboRecordSource_Change()
  592.   Set mrecRS = Nothing
  593.   lstFields.Clear
  594.   lstIncludedFields.Clear
  595. End Sub
  596. Private Sub cboRecordSource_Click()
  597.   Call cboRecordSource_LostFocus
  598. End Sub
  599. Private Sub cboRecordSource_LostFocus()
  600.   On Error GoTo RSErr
  601.   Dim i As Integer
  602.   Dim fld As Field
  603.   If Len(cboRecordSource.Text) = 0 Then Exit Sub
  604.   Screen.MousePointer = 11
  605.   'this code clears out the current field list
  606.   'and gets the new fields from the new recordset
  607.   If mrecRS Is Nothing Then
  608.     Set mrecRS = mdbCurrentDB.OpenRecordset(cboRecordSource.Text)
  609.     For Each fld In mrecRS.Fields
  610.       lstFields.AddItem fld.Name
  611.     Next
  612.   ElseIf mrecRS.Name <> cboRecordSource.Text Then
  613.     lstFields.Clear
  614.     lstIncludedFields.Clear
  615.     Set mrecRS = mdbCurrentDB.OpenRecordset(cboRecordSource.Text)
  616.     For Each fld In mrecRS.Fields
  617.       lstFields.AddItem fld.Name
  618.     Next
  619.   End If
  620.   Screen.MousePointer = 0
  621.   Exit Sub
  622. RSErr:
  623.   Screen.MousePointer = 0
  624.   MsgBox Err.Description
  625.   Exit Sub
  626. End Sub
  627. Private Sub cmdCancel_Click()
  628. Unload Me 'and do nothing else
  629. End Sub
  630. Private Sub cmdFinish_Click()
  631.   If Len(txtFormName.Text) = 0 Then
  632.     MsgBox "Form Name cannot be blank!", 16
  633.     txtFormName.SetFocus
  634.     Exit Sub
  635.   End If
  636.   If InStr(txtFormName.Text, " ") > 0 Then
  637.     MsgBox "Form Name cannot have spaces in it!", 16
  638.     txtFormName.SetFocus
  639.     Exit Sub
  640.   End If
  641.   If mdbCurrentDB Is Nothing Then
  642.     MsgBox "You must open a Database!", 16
  643.     Exit Sub
  644.   End If
  645.   If Len(cboRecordSource.Text) = 0 Then
  646.     MsgBox "You must enter a RecordSource!", 16
  647.     Exit Sub
  648.   End If
  649.   If lstIncludedFields.ListCount = 0 Then
  650.     MsgBox "You must include some Columns!", 16
  651.     Exit Sub
  652.   End If
  653.         
  654.    Screen.MousePointer = vbHourglass
  655.   If chkOnScreen.Value = vbChecked Then
  656.     BuildFormOnScreen
  657.   Else
  658.     'BuildFormFile 'we dont do this in this version
  659.   End If
  660.   Screen.MousePointer = vbDefault
  661.   MsgBox "The Data Form Wizard by:" & _
  662.     vbCrLf & "Gervase Gallant (email: ggallant@gnn.com)" & _
  663.     vbCrLf & "from the Data Form Designer source code.", 48, "Wizard"
  664.   Unload Me
  665. End Sub
  666. Private Sub cmdMove_Click(Index As Integer)
  667. Const Step_previous = 1
  668. Const Step_next = 0
  669. Static ThisIndex As Integer
  670. 'start at 1, not step 0
  671. If ThisIndex = 0 Then ThisIndex = 1
  672. Select Case Index
  673. Case Step_previous
  674.     ThisIndex = ThisIndex - 1
  675.     fraStep(ThisIndex).ZOrder 0
  676.     If ThisIndex = 1 Then
  677.         cmdMove(Index).Enabled = False
  678.     Else
  679.         cmdMove(1).Enabled = True
  680.         cmdMove(0).Enabled = True
  681.     End If
  682. Case Step_next
  683.     ThisIndex = ThisIndex + 1
  684.     fraStep(ThisIndex).ZOrder 0
  685.     If ThisIndex = 5 Then
  686.         cmdMove(Index).Enabled = False
  687.     Else
  688.         cmdMove(0).Enabled = True
  689.         cmdMove(1).Enabled = True
  690.     End If
  691. End Select
  692. 'when to enable the Finish button
  693. If ThisIndex = 5 Then
  694.     cmdFinish.Enabled = True
  695.     cmdFinish.Enabled = False
  696. End If
  697. End Sub
  698. Private Sub cmdMoveFields_Click(Index As Integer)
  699.   Dim i As Integer
  700.   Select Case Index
  701.     Case 0
  702.       For i = 0 To lstFields.ListCount - 1
  703.         lstIncludedFields.AddItem lstFields.List(i)
  704.       Next
  705.       lstFields.Clear
  706.     Case 1
  707.       If lstFields.ListIndex = -1 Then Exit Sub
  708.       For i = lstFields.ListCount - 1 To 0 Step -1
  709.         If lstFields.Selected(i) = True Then
  710.           lstIncludedFields.AddItem lstFields.List(i)
  711.           lstFields.RemoveItem i
  712.         End If
  713.       Next
  714.     Case 2
  715.       If lstIncludedFields.ListIndex = -1 Then Exit Sub
  716.       For i = lstIncludedFields.ListCount - 1 To 0 Step -1
  717.         If lstIncludedFields.Selected(i) = True Then
  718.           lstFields.AddItem lstIncludedFields.List(i)
  719.           lstIncludedFields.RemoveItem i
  720.         End If
  721.       Next
  722.     Case 3
  723.       For i = 0 To lstIncludedFields.ListCount - 1
  724.         lstFields.AddItem lstIncludedFields.List(i)
  725.       Next
  726.       lstIncludedFields.Clear
  727.   End Select
  728. End Sub
  729. Private Sub cmdSQL_Click()
  730. 'added by Gervase
  731. End Sub
  732. Sub Form_Load()
  733. Dim i As Integer
  734.   Me.Height = 4750
  735.   Me.Width = fraStep(1).Width + 350
  736.   'center it on the screen
  737.   Me.Top = (Screen.Height - Me.Height) \ 2
  738.   Me.Left = (Screen.Width - Me.Width) \ 2
  739.   #If Win32 Then
  740.     chkOnScreen.Value = vbChecked
  741.     chkOnScreen.Visible = False
  742.   #End If
  743.   cboConnect.ListIndex = 0
  744. 'position the frames
  745. For i = 1 To 5
  746.     fraStep(i).Top = 100
  747.     fraStep(i).Left = 100
  748. 'move first frame to top
  749. fraStep(1).ZOrder 0
  750. 'position the buttons
  751. For i = 0 To 1
  752.     cmdMove(i).Top = fraStep(1).Top + fraStep(1).Height + 100
  753. cmdFinish.Top = fraStep(1).Top + fraStep(1).Height + 100
  754. cmdCancel.Top = fraStep(1).Top + fraStep(1).Height + 100
  755. End Sub
  756. Private Sub Form_Unload(Cancel As Integer)
  757.   On Error Resume Next
  758.   Dim rsTmp As Recordset
  759.   'close all open recordsets
  760.   For Each rsTmp In mdbCurrentDB.Recordsets
  761.     rsTmp.Close
  762.   Next
  763.   'close the database
  764.   mdbCurrentDB.Close
  765. End Sub
  766. Sub lstIncludedFields_DragDrop(Source As Control, X As Single, Y As Single)
  767.   Dim sTmp As String
  768.   Dim nPos As Integer
  769.   If Source = lstIncludedFields Then
  770.     If lstIncludedFields.ListIndex >= 0 Then
  771.       sTmp = lstIncludedFields.List(lstIncludedFields.ListIndex)
  772.       nPos = (Y / TextHeight(sTmp)) + lstIncludedFields.TopIndex
  773.       'check for the last item
  774.       If nPos > lstIncludedFields.ListCount Then
  775.         nPos = lstIncludedFields.ListCount
  776.       End If
  777.       lstIncludedFields.AddItem sTmp, nPos
  778.       If lstIncludedFields.ListIndex > nPos Then
  779.         lstIncludedFields.RemoveItem lstIncludedFields.ListIndex + 1
  780.       Else
  781.         lstIncludedFields.RemoveItem lstIncludedFields.ListIndex
  782.       End If
  783.     End If
  784.     Source.MousePointer = 0
  785.   End If
  786. End Sub
  787. Private Sub cmdOpenDB_Click()
  788.   On Error GoTo OpenError
  789.   Dim sConnect As String
  790.   Dim sDatabaseName As String
  791.   Dim tdf As TableDef
  792.   Dim qdf As QueryDef
  793.   Dim fld As Field
  794.   Select Case mnDataType
  795.     Case gnDT_ACCESS
  796.       dlgDBOpen.Filter = "Access DBs (*.mdb)|*.mdb|All Files (*.*)|*.*"
  797.       dlgDBOpen.DialogTitle = "Open MS Access Database"
  798.     Case gnDT_BTRIEVE
  799.       dlgDBOpen.Filter = "Btrieve DBs (FILE.DDF)|FILE.DDF"
  800.       dlgDBOpen.DialogTitle = "Open Btrieve Database"
  801.     Case gnDT_DBASEIII
  802.       dlgDBOpen.Filter = "dBASE III DBs (*.dbf)|*.dbf"
  803.       dlgDBOpen.DialogTitle = "Open dBASE III Database"
  804.     Case gnDT_DBASEIV
  805.       dlgDBOpen.Filter = "dBASE IV DBs (*.dbf)|*.dbf"
  806.       dlgDBOpen.DialogTitle = "Open dBASE IV Database"
  807.     Case gnDT_FOXPRO20
  808.       dlgDBOpen.Filter = "FoxPro DBs (*.dbf)|*.dbf"
  809.       dlgDBOpen.DialogTitle = "Open FoxPro 2.0 Database"
  810.     Case gnDT_FOXPRO25
  811.       dlgDBOpen.Filter = "FoxPro DBs (*.dbf)|*.dbf"
  812.       dlgDBOpen.DialogTitle = "Open FoxPro 2.5 Database"
  813.     Case gnDT_FOXPRO26
  814.       dlgDBOpen.Filter = "FoxPro DBs (*.dbf)|*.dbf"
  815.       dlgDBOpen.DialogTitle = "Open FoxPro 2.6 Database"
  816.     Case gnDT_PARADOX3X
  817.       dlgDBOpen.Filter = "Paradox DBs (*.db)|*.db"
  818.       dlgDBOpen.DialogTitle = "Open Paradox 3.X Database"
  819.     Case gnDT_PARADOX4X
  820.       dlgDBOpen.Filter = "Paradox DBs (*.db)|*.db"
  821.       dlgDBOpen.DialogTitle = "Open Paradox 4.X Database"
  822.     Case Else
  823.       If UCase(Left(cboConnect.Text, 4)) = "ODBC" Then
  824.         'default to ODBC
  825.         mnDataType = gnDT_ODBC
  826.       Else
  827.         Beep
  828.         MsgBox "Invalid Connect String!", 48
  829.         Exit Sub
  830.       End If
  831.   End Select
  832.   If mnDataType <> gnDT_ODBC Then
  833.     With dlgDBOpen
  834.       .FilterIndex = 1
  835.       .FileName = msDBName  '""
  836.       .CancelError = True
  837.       .Flags = &H4
  838.       .Action = 1
  839.     End With
  840.     msDBName = dlgDBOpen.FileName
  841.   Else
  842.     msDBName = ""
  843.   End If
  844.   lblDatabaseName.Caption = msDBName
  845.   cboRecordSource.Clear
  846.   lstSQL.Clear
  847.   Set mrecRS = Nothing
  848.   lstFields.Clear
  849.   lstIncludedFields.Clear
  850.   Me.Refresh       'repaint the form to get rid og the common dialog
  851.   Select Case mnDataType
  852.     Case gnDT_ACCESS
  853.       sConnect = ""
  854.       sDatabaseName = msDBName
  855.     Case gnDT_DBASEIII
  856.       sConnect = "dBASE III"
  857.       sDatabaseName = StripFileName(msDBName)
  858.     Case gnDT_DBASEIV
  859.       sConnect = "dBASE IV"
  860.       sDatabaseName = StripFileName(msDBName)
  861.     Case gnDT_FOXPRO20
  862.       sConnect = "FoxPro 2.0"
  863.       sDatabaseName = StripFileName(msDBName)
  864.     Case gnDT_FOXPRO25
  865.       sConnect = "FoxPro 2.5"
  866.       sDatabaseName = StripFileName(msDBName)
  867.     Case gnDT_PARADOX3X
  868.       sConnect = "Paradox 3.X"
  869.       sDatabaseName = StripFileName(msDBName)
  870.     Case gnDT_PARADOX4X
  871.       sConnect = "Paradox 4.X"
  872.       sDatabaseName = StripFileName(msDBName)
  873.     Case gnDT_BTRIEVE
  874.       sConnect = "Btrieve;"
  875.       sDatabaseName = msDBName
  876.     Case Else
  877.       sConnect = cboConnect.Text
  878.       sDatabaseName = msDBName
  879.   End Select
  880.   Screen.MousePointer = 11 'set the hourglass
  881.   Set mdbCurrentDB = OpenDatabase(sDatabaseName, False, True, sConnect)
  882.   'set the connect string for an ODBC datasource
  883.   If mnDataType = gnDT_ODBC Then
  884.     cboConnect.Text = mdbCurrentDB.Connect
  885.   End If
  886.   For Each tdf In mdbCurrentDB.TableDefs
  887.     If (tdf.Attributes And &H80000002) = 0 Then
  888.       cboRecordSource.AddItem tdf.Name
  889.       lstSQL.AddItem "TABLE: " & tdf.Name
  890.       lstSQL.AddItem "------------------------"
  891.       For Each fld In tdf.Fields
  892.         lstSQL.AddItem tdf.Name & "." & fld.Name
  893.       Next
  894.       lstSQL.AddItem "------------------------"
  895.     End If
  896.   Next
  897.   If mnDataType = gnDT_ACCESS Then
  898.     For Each qdf In mdbCurrentDB.QueryDefs
  899.       cboRecordSource.AddItem qdf.Name
  900.       lstSQL.AddItem "QUERYDEF: " & qdf.Name
  901.       lstSQL.AddItem "------------------------"
  902.       For Each fld In qdf.Fields
  903.         lstSQL.AddItem qdf.Name & "." & fld.Name
  904.       Next
  905.       lstSQL.AddItem "------------------------"
  906.     Next
  907.   End If
  908.   cboRecordSource.ListIndex = 0
  909.   Screen.MousePointer = 0 'unset the hourglass
  910.   Exit Sub
  911. OpenError:
  912.   Screen.MousePointer = 0 'unset the hourglass
  913.   If Err <> 32755 Then     'check for common dialog cancelled
  914.     MsgBox Err.Description
  915.   End If
  916.   Exit Sub
  917. End Sub
  918. Private Sub lstIncludedFields_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  919.   If Button = 1 Then lstIncludedFields.Drag
  920. End Sub
  921. Sub BuildFormOnScreen()
  922.   On Error GoTo BuildErr
  923.   Dim i As Integer, iThis As Integer, iAddtoTop As Integer
  924.   Dim sTmp As String
  925.   Dim nNumFlds As Integer
  926.   Dim frmNewForm As vbide.FormTemplate
  927.   Dim nButtonTop As Integer
  928.   Dim iHiddenLeft As Integer
  929.   Dim iFieldHeight As Integer
  930.  'just how many fields do you want to display??
  931.   Const MAX_Fields = 50
  932.   Const QB_RED = 12
  933.   'assign height of fields
  934.   Select Case iScreenStyle
  935.   Case Screen_3d
  936.     iFieldHeight = 320 'standard height of 3d fields
  937.   Case Screen_2d
  938.     iFieldHeight = 285 '2d height
  939.   Case Screen_View
  940.     iFieldHeight = 225   'view only (transparent, borderless...)
  941.   End Select
  942.   'deal with too many fields
  943.   If lstIncludedFields.ListCount > MAX_Fields Then
  944.     MsgBox "You have requested" & Str$(lstIncludedFields.ListCount) & _
  945.           ". However, only" & Str$(MAX_Fields) & " can be displayed.", _
  946.           vbExclamation, App.Title
  947.     nNumFlds = MAX_Fields
  948.   Else
  949.     nNumFlds = lstIncludedFields.ListCount
  950.   End If
  951.   lstOLECtls.Clear
  952.   'create the new form
  953.   Set frmNewForm = gobjIDEAppInst.ActiveProject.AddFormTemplate()
  954. 'make room for the headline and line
  955. If txtHeadline.Text = "" Then
  956.   iAddtoTop = 0
  957.   iAddtoTop = 700
  958. End If
  959.   'form height = iFieldHeight * numflds + 1260 for buttons and data control
  960.   'form width = 5640
  961.   With frmNewForm.Properties
  962.     .Item("Caption") = Left(mrecRS.Name, 32)
  963.     .Item("Height") = 1115 + (nNumFlds * iFieldHeight) + iAddtoTop
  964.     .Item("Name") = "frm" & txtFormName.Text
  965.     .Item("Width") = 5640
  966.     .Item("Left") = 1050
  967.   End With
  968.   iHiddenLeft = -5640
  969.    'add headline to top
  970.    If txtHeadline.Text <> "" Then
  971.     With frmNewForm.ControlTemplates.Add("label").Properties
  972.      .Item("Name") = "lblHeadline"
  973.      .Item("left") = 120
  974.      .Item("top") = 50
  975.      .Item("caption") = txtHeadline.Text
  976.      .Item("autosize") = True
  977.      .Item("forecolor") = QBColor(QB_RED)
  978.      
  979.      '*************************************
  980.      'AAARGH!!!!!!
  981.      'ATTEMPTS BELOW: all of these failed
  982.      '.Item("font").Properties("bold").Value = 0
  983.      '.Item("font(0)") = True
  984.      '.Item("font(3)") = 24
  985.      '.item("font.size")  = 24
  986.      
  987.      'YOU CAN actually nest like this at runtime
  988.      'but not here
  989.       'with .item("font")
  990.         '.Item("bold") = True
  991.       'end with
  992.       '*******************************************
  993.      
  994.    End With
  995. '***********************************************************************
  996. ' since the headline was the first control I made, I was able to reference it
  997. ' as the first element of the ControlTemplates collection, which spared me
  998. 'from having to loop through the collection to find my headline
  999. frmNewForm.ControlTemplates(0).Properties("font").Value("bold").Value = False
  1000. frmNewForm.ControlTemplates(0).Properties("font").Value("size").Value = 24
  1001.   If chkLineUnder.Value Then
  1002.         With frmNewForm.ControlTemplates.Add("line").Properties
  1003.             .Item("x1") = 120
  1004.             .Item("Y1") = iAddtoTop - 50
  1005.             .Item("x2") = 5640 - 240
  1006.             .Item("y2") = iAddtoTop - 50
  1007.             .Item("Name") = "lineHeadline"
  1008.             .Item("BorderWidth") = 1
  1009.             .Item("bordercolor") = QBColor(12)
  1010.            
  1011.         End With
  1012.     End If
  1013.   End If
  1014.   'labels.left") = 120, .width") = 1815, .height = 255
  1015.   'fields.left = 2040, .width = 3375, .height = 285
  1016.   For i = 0 To nNumFlds - 1
  1017.     sTmp = lstIncludedFields.List(i)
  1018.     With frmNewForm.ControlTemplates.Add("Label").Properties
  1019.       .Item("Left") = iHiddenLeft
  1020.       .Item("Caption") = sTmp & ":"
  1021.       .Item("Height") = 255
  1022.       .Item("Index") = i
  1023.       .Item("Name") = "lblLabels"
  1024.       .Item("Top") = (i * iFieldHeight) + 60 + iAddtoTop
  1025.       .Item("Width") = 1815
  1026.       .Item("Left") = 120
  1027.     End With
  1028.     If mrecRS.Fields(sTmp).Type = 1 Then
  1029.       'true/false field
  1030.       With frmNewForm.ControlTemplates.Add("CheckBox").Properties
  1031.         .Item("Left") = iHiddenLeft
  1032.         .Item("Caption") = ""
  1033.         .Item("Height") = 285
  1034.         .Item("Index") = i
  1035.         .Item("Name") = "chkFields"
  1036.         .Item("Top") = (i * iFieldHeight) + 40 + iAddtoTop
  1037.         .Item("Width") = 3375
  1038.         .Item("DataSource") = "Data1"
  1039.         .Item("DataField") = sTmp
  1040.         .Item("Left") = 2040
  1041.       End With
  1042.     ElseIf mrecRS.Fields(sTmp).Type = 11 Then
  1043.       'picture field
  1044.       With frmNewForm.ControlTemplates.Add("OLE").Properties
  1045.         .Item("Left") = iHiddenLeft
  1046.         .Item("Height") = 285
  1047.         .Item("Name") = "oleField" & i
  1048.         .Item("OLETypeAllowed") = 1
  1049.         .Item("Top") = (i * iFieldHeight) + 40 + iAddtoTop
  1050.         .Item("Width") = 3375
  1051.         .Item("DataSource") = "Data1"
  1052.         .Item("DataField") = sTmp
  1053.         .Item("Left") = 2040
  1054.       End With
  1055.       SendKeys "{Esc}"
  1056.       lstOLECtls.AddItem i
  1057.     Else
  1058.       With frmNewForm.ControlTemplates.Add("TextBox").Properties
  1059.         .Item("Left") = iHiddenLeft
  1060.         .Item("Index") = i
  1061.         .Item("Name") = "txtFields"
  1062.         .Item("Text") = ""
  1063.         If mrecRS.Fields(sTmp).Type < 10 Then
  1064.           'numeric or date
  1065.           .Item("Width") = 1935
  1066.         Else
  1067.           'string or memo
  1068.           .Item("Width") = 3375
  1069.       
  1070.         End If
  1071.         .Item("DataSource") = "Data1"
  1072.         .Item("DataField") = sTmp
  1073.         If mrecRS.Fields(sTmp).Type = 10 Then
  1074.           .Item("Height") = 285
  1075.           .Item("Top") = (i * iFieldHeight) + 40 + iAddtoTop
  1076.           .Item("MaxLength") = mrecRS.Fields(sTmp).Size
  1077.         ElseIf mrecRS.Fields(sTmp).Type = 12 Then
  1078.           .Item("Height") = 310
  1079.           .Item("Top") = (i * iFieldHeight) + 30 + iAddtoTop
  1080.           .Item("MultiLine") = True
  1081.           .Item("ScrollBars") = 2
  1082.         Else
  1083.           .Item("Height") = 285
  1084.           .Item("Top") = (i * iFieldHeight) + 40 + iAddtoTop
  1085.         End If
  1086.         .Item("Left") = 2040
  1087.         
  1088.         '**************************************
  1089.         'APPEARANCE: how you switch from 3d to 2d to Flat
  1090.         
  1091.         
  1092.         Select Case iScreenStyle
  1093.             
  1094.             Case Screen_3d
  1095.                 'do nothing
  1096.                 .Item("appearance") = 1
  1097.             Case Screen_2d
  1098.                 .Item("Appearance") = 0
  1099.             Case Screen_View
  1100.                 .Item("Appearance") = 0
  1101.                 .Item("backcolor") = &HE0E0E0 'grey it out??
  1102.                 .Item("borderstyle") = 0
  1103.                 .Item("Locked") = True
  1104.         End Select
  1105.             
  1106.         
  1107.         '*******************************************************
  1108.       End With
  1109.     End If
  1110.   Next
  1111.   nButtonTop = i * iFieldHeight + 120  'still can't figure why an extra 120!
  1112.   'add the data control and buttons
  1113.   With frmNewForm.ControlTemplates.Add("Data").Properties
  1114.     .Item("Left") = iHiddenLeft
  1115.     .Item("Caption") = ""
  1116.     .Item("DatabaseName") = mdbCurrentDB.Name
  1117.     .Item("Connect") = mdbCurrentDB.Connect
  1118.     .Item("RecordSource") = cboRecordSource.Text
  1119.     .Item("Align") = 2 'toolbar type
  1120.   End With
  1121. '*******************************************************
  1122. 'if screen is View then don't add, delete,update,refresh
  1123.   If iScreenStyle <> Screen_View Then
  1124.     With frmNewForm.ControlTemplates.Add("CommandButton").Properties
  1125.       .Item("Left") = iHiddenLeft
  1126.       .Item("Caption") = "&Add"
  1127.       .Item("Height") = 300
  1128.       .Item("Name") = "cmdAdd"
  1129.       .Item("Top") = nButtonTop + iAddtoTop
  1130.       .Item("Width") = 975
  1131.       .Item("Left") = 120
  1132.     End With
  1133.     With frmNewForm.ControlTemplates.Add("CommandButton").Properties
  1134.     .Item("Left") = iHiddenLeft
  1135.     .Item("Caption") = "&Delete"
  1136.     .Item("Height") = 300
  1137.     .Item("Name") = "cmdDelete"
  1138.     .Item("Top") = nButtonTop + iAddtoTop
  1139.     .Item("Width") = 975
  1140.     .Item("Left") = 1200
  1141.   End With
  1142.   With frmNewForm.ControlTemplates.Add("CommandButton").Properties
  1143.     .Item("Left") = iHiddenLeft
  1144.     .Item("Caption") = "&Refresh"
  1145.     .Item("Height") = 300
  1146.     .Item("Name") = "cmdRefresh"
  1147.     .Item("Top") = nButtonTop + iAddtoTop
  1148.     .Item("Width") = 975
  1149.     .Item("Left") = 2280
  1150.   End With
  1151.   With frmNewForm.ControlTemplates.Add("CommandButton").Properties
  1152.     .Item("Left") = iHiddenLeft
  1153.     .Item("Caption") = "&Update"
  1154.     .Item("Height") = 300
  1155.     .Item("Name") = "cmdUpdate"
  1156.     .Item("Top") = nButtonTop + iAddtoTop
  1157.     .Item("Width") = 975
  1158.     .Item("Left") = 3360
  1159.   End With
  1160. End If
  1161.   With frmNewForm.ControlTemplates.Add("CommandButton").Properties
  1162.     .Item("Left") = iHiddenLeft
  1163.     .Item("Caption") = "&Close"
  1164.     .Item("Height") = 300
  1165.     .Item("Name") = "cmdClose"
  1166.     .Item("Top") = nButtonTop + iAddtoTop
  1167.     .Item("Width") = 975
  1168.     .Item("Left") = 4440
  1169.   End With
  1170.   'add the code to the form
  1171.   Dim fh As Integer
  1172.   fh = FreeFile
  1173.   Open App.Path & "\DFD_FRM.MOD" For Output As fh
  1174.   WriteFrmCode fh
  1175.   Close fh
  1176.   frmNewForm.InsertFile App.Path & "\DFD_FRM.MOD"
  1177.   Kill App.Path & "\DFD_FRM.MOD"
  1178.   'save the new form
  1179.   gobjIDEAppInst.ActiveProject.SelectedComponents(0).SaveAs (gobjIDEAppInst.LastUsedPath & "\" & txtFormName & ".FRM")
  1180.   'set the form back to defaults
  1181.   txtFormName.Text = ""
  1182.   cboRecordSource.Text = ""
  1183.   'try to set focus back to the form
  1184.   Me.SetFocus
  1185.   txtFormName.SetFocus
  1186.   Exit Sub
  1187. BuildErr:
  1188.   MsgBox Err.Description
  1189.   Resume Next
  1190. End Sub
  1191. Sub BuildFormFile()
  1192.   On Error GoTo BuildFErr
  1193.   Dim i As Integer
  1194.   Dim sTmp As String
  1195.   Dim nNumFlds As Integer
  1196.   Dim frmNewForm As Object
  1197.   Dim ctlNewControl As Object
  1198.   Dim nButtonTop As Integer
  1199.   'create and open the file
  1200.   Dim nFileHnd As Integer
  1201.   nFileHnd = FreeFile
  1202.   Open gobjIDEAppInst.LastUsedPath & "\" & txtFormName & ".FRM" For Output As nFileHnd
  1203.   Print #nFileHnd, "VERSION 4.00"
  1204.   nNumFlds = lstIncludedFields.ListCount
  1205.   lstOLECtls.Clear
  1206.   Print #nFileHnd, "Begin VB.Form frm" & txtFormName.Text
  1207.   'form height = 320 * numflds + 1260 for buttons and data control
  1208.   'form width = 5640
  1209.   Print #nFileHnd, "   Caption = """ & Left(mrecRS.Name, 32) & """"
  1210.   Print #nFileHnd, "   Height       = " & 1115 + (nNumFlds * 320)
  1211.   Print #nFileHnd, "   Left         = 2400"
  1212.   Print #nFileHnd, "   Top          = 2040"
  1213.   Print #nFileHnd, "   Width        = 5640"
  1214.   'labels.left = 120, .width = 1815, .height = 255
  1215.   'fields.left = 2040, .width = 3375, .height = 285
  1216.   For i = 0 To nNumFlds - 1
  1217.     sTmp = lstIncludedFields.List(i)
  1218.     Print #nFileHnd, "   Begin VB.Label lblLabels"
  1219.     Print #nFileHnd, "      Caption = """ & sTmp & ":"""
  1220.     Print #nFileHnd, "      Height  = 255"
  1221.     Print #nFileHnd, "      Index   = " & i
  1222.     Print #nFileHnd, "      Left    = 120"
  1223.     Print #nFileHnd, "      Top     = " & (i * 320) + 60
  1224.     Print #nFileHnd, "      Width   = 1815"
  1225.     Print #nFileHnd, "   End"
  1226.     If mrecRS.Fields(sTmp).Type = 1 Then
  1227.       'true/false field
  1228.       Print #nFileHnd, "   Begin VB.CheckBox chkField" & i
  1229.       Print #nFileHnd, "      DataField  = """ & sTmp & """"
  1230.       Print #nFileHnd, "      DataSource = ""Data1"""
  1231.       Print #nFileHnd, "      Height     = 285"
  1232.       Print #nFileHnd, "      Index      = " & i
  1233.       Print #nFileHnd, "      Left       = 2040"
  1234.       Print #nFileHnd, "      Top        = " & (i * 320) + 40
  1235.       Print #nFileHnd, "      Width      = 3375"
  1236.       Print #nFileHnd, "   End"
  1237.     ElseIf mrecRS.Fields(sTmp).Type = 11 Then
  1238.       'picture field
  1239.       Print #nFileHnd, "   Begin VB.OLE oleField" & i
  1240.       Print #nFileHnd, "      DataField      = """ & sTmp & """"
  1241.       Print #nFileHnd, "      DataSource     = ""Data1"""
  1242.       Print #nFileHnd, "      Height         = 285"
  1243.       Print #nFileHnd, "      Left           = 2040"
  1244.       Print #nFileHnd, "      OLETypeAllowed = 1"
  1245.       Print #nFileHnd, "      Top            = " & (i * 320) + 40
  1246.       Print #nFileHnd, "      Width          = 3375"
  1247.       Print #nFileHnd, "   End"
  1248.       lstOLECtls.AddItem i
  1249.     Else
  1250.       Print #nFileHnd, "   Begin VB.TextBox txtField" & i
  1251.       Print #nFileHnd, "      DataField  = """ & sTmp & """"
  1252.       Print #nFileHnd, "      DataSource = ""Data1"""
  1253.       If mrecRS.Fields(sTmp).Type = 12 Then
  1254.         Print #nFileHnd, "      Height     = 310"
  1255.       Else
  1256.         Print #nFileHnd, "      Height     = 285"
  1257.       End If
  1258.       Print #nFileHnd, "      Index      = " & i
  1259.       Print #nFileHnd, "      Left       = 2040"
  1260.       If mrecRS.Fields(sTmp).Type = 10 Then
  1261.         Print #nFileHnd, "      MaxLength   = " & mrecRS.Fields(sTmp).Size
  1262.       End If
  1263.       If mrecRS.Fields(sTmp).Type = 12 Then
  1264.         Print #nFileHnd, "      MultiLine   = True"
  1265.       End If
  1266.       If mrecRS.Fields(sTmp).Type = 12 Then
  1267.         Print #nFileHnd, "      ScrollBars  = 2"
  1268.       End If
  1269.       Print #nFileHnd, "      Top        = " & (i * 320) + 40
  1270.       Print #nFileHnd, "      Text       = """""
  1271.       If mrecRS.Fields(sTmp).Type < 10 Then
  1272.         'numeric or date
  1273.         Print #nFileHnd, "      Width      = 1935"
  1274.       Else
  1275.         'string or memo
  1276.         Print #nFileHnd, "      Width      = 3375"
  1277.       End If
  1278.       Print #nFileHnd, "   End"
  1279.     End If
  1280.   Next
  1281.   nButtonTop = (((i - 1) * 320) + 40) + 340
  1282.   'add the data control and buttons
  1283.   Print #nFileHnd, "   Begin VB.Data Data1"
  1284.   Print #nFileHnd, "      Align        = 2"
  1285.   Print #nFileHnd, "      Caption      = """""
  1286.   Print #nFileHnd, "      Connect      = """ & mdbCurrentDB.Connect & """"
  1287.   Print #nFileHnd, "      DatabaseName = """ & mdbCurrentDB.Name & """"
  1288.   Print #nFileHnd, "      RecordSource = """ & cboRecordSource.Text & """"
  1289.   Print #nFileHnd, "   End"
  1290.   Print #nFileHnd, "   Begin VB.CommandButton cmdAdd"
  1291.   Print #nFileHnd, "      Caption      = ""&Add"""
  1292.   Print #nFileHnd, "      Height       = 300"
  1293.   Print #nFileHnd, "      Left         = 120"
  1294.   Print #nFileHnd, "      Top          = " & nButtonTop
  1295.   Print #nFileHnd, "      Width        = 975"
  1296.   Print #nFileHnd, "   End"
  1297.   Print #nFileHnd, "   Begin VB.CommandButton cmdDelete"
  1298.   Print #nFileHnd, "      Caption      = ""&Delete"""
  1299.   Print #nFileHnd, "      Height       = 300"
  1300.   Print #nFileHnd, "      Left         = 1200"
  1301.   Print #nFileHnd, "      Top          = " & nButtonTop
  1302.   Print #nFileHnd, "      Width        = 975"
  1303.   Print #nFileHnd, "   End"
  1304.   Print #nFileHnd, "   Begin VB.CommandButton cmdRefresh"
  1305.   Print #nFileHnd, "      Caption      = ""&Refresh"""
  1306.   Print #nFileHnd, "      Height       = 300"
  1307.   Print #nFileHnd, "      Left         = 2280"
  1308.   Print #nFileHnd, "      Top          = " & nButtonTop
  1309.   Print #nFileHnd, "      Width        = 975"
  1310.   Print #nFileHnd, "   End"
  1311.   Print #nFileHnd, "   Begin VB.CommandButton cmdUpdate"
  1312.   Print #nFileHnd, "      Caption      = ""&Update"""
  1313.   Print #nFileHnd, "      Height       = 300"
  1314.   Print #nFileHnd, "      Left         = 3360"
  1315.   Print #nFileHnd, "      Top          = " & nButtonTop
  1316.   Print #nFileHnd, "      Width        = 975"
  1317.   Print #nFileHnd, "   End"
  1318.   Print #nFileHnd, "   Begin VB.CommandButton cmdClose"
  1319.   Print #nFileHnd, "      Caption      = ""&Close"""
  1320.   Print #nFileHnd, "      Height       = 300"
  1321.   Print #nFileHnd, "      Left         = 4440"
  1322.   Print #nFileHnd, "      Top          = " & nButtonTop
  1323.   Print #nFileHnd, "      Width        = 975"
  1324.   Print #nFileHnd, "   End"
  1325.   Print #nFileHnd, "End"
  1326.   Print #nFileHnd, ""
  1327.   Print #nFileHnd, "Attribute VB_Name = ""frm" & txtFormName.Text & """"
  1328.   Print #nFileHnd, "Attribute VB_Creatable = False"
  1329.   Print #nFileHnd, "Attribute VB_Exposed = False"
  1330.   Print #nFileHnd, "Option Explicit"
  1331.   Print #nFileHnd, ""
  1332.   'add the code to the form
  1333.   WriteFrmCode nFileHnd
  1334.   Close nFileHnd
  1335.   'add the new form to the project
  1336.   gobjIDEAppInst.ActiveProject.AddFile gobjIDEAppInst.LastUsedPath & "\" & txtFormName & ".FRM"
  1337.   'set the form back to defaults
  1338.   txtFormName.Text = ""
  1339.   cboRecordSource.Text = ""
  1340.   'try to set focus back to the form
  1341.   Me.SetFocus
  1342.   txtFormName.SetFocus
  1343.   Exit Sub
  1344. BuildFErr:
  1345.   MsgBox Err.Description
  1346.   Exit Sub
  1347. End Sub
  1348. Private Sub lstSQL_Click()
  1349. End Sub
  1350. Private Sub optLook_Click(Index As Integer)
  1351. iScreenStyle = Index
  1352. End Sub
  1353.